package com.itheima;

import com.itheima.domain.Card;
import com.itheima.mapper.OneToOneMapper;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.Test;

import java.io.IOException;
import java.io.InputStream;
import java.sql.SQLException;
import java.util.List;

public class OnetooneOneToOneMapper {
    @Test
    public void selectAll() throws IOException, SQLException {
        InputStream is = Resources.getResourceAsStream("MybatisConfig.xml");
        SqlSessionFactory build = new SqlSessionFactoryBuilder().build(is);
        SqlSession sqlSession = build.openSession();
        OneToOneMapper mapper = sqlSession.getMapper(OneToOneMapper.class);
        List<Card> all = mapper.selectAll();
        for (Card card : all) {
            System.out.println(card);
        }
    }
}
